<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<html>
	<head>
		<title>公共平台</title>
		<!-- 样式文件的引入 -->
		<link href="${ctx}/commons/css/top.css" rel="stylesheet" type="text/css"/>
			<!-- 样式文件的引入 -->
		<link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
		<link rel="shortcut icon" href="${ctx }/website/homepage/favicon.ico"> 
		<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="${ctx}/commons/js/uploadify/uploadify.css">
		<!-- jqueryUI JS文件的引入 -->
		<script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/htmicDate.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/uploadify/jquery.uploadify.min.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
		<link rel="stylesheet" type="text/css" href="${ctx}/commons/css/flow/flow.css">
		<script type="text/javascript" src="${ctx}/commons/js/flow/GooFunc.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/flow/flow.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/flow/flow_fn.js"></script>
		<script type="text/javascript" src="${ctx}/commons/js/flow/json2.js"></script>
		<!-- jqueryUI国际化 -->
		<script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
		<!-- 开发使用的公用js方法 -->
		<script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
		<!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
		<script type="text/javascript">var ctx = '${ctx}';var actionExt = "action";var i18n = new Object();</script>
		<script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function() {
				$.ajax({
					type: "get",
					timeout:30000,
					url:  "${ctx}/portal/top/userModel?r="+new Date().getTime(),
					success: function(data){
						if(data == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
								return ;
							}
						}else{
							$('#menu').html(data);
							$.parser.parse($('#menu'));
						}
					},
					error: function(res){
						var data = $.trim(res.responseText);
						if(data == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
								return ;
							}
						}
					}
				});
				var hrefUrl = '${param.hrefUrl}';
				if(hrefUrl != ''){
					window.open(hrefUrl,'mainAreaFrame');
				}
			});

			function openNewWin(hrefUrl){
				window.open(hrefUrl);
			}

			function openMenu(hrefUrl,titleName){
				/*var newTab = $('#menu_page').tabs('getTab',titleName);
				var tabIndex = $('#menu_page').tabs('getTabIndex',newTab);
				if(tabIndex == -1){
					$('#menu_page').tabs('add',{
						title: titleName,
						selected: true,
						content : "<iframe src='"+hrefUrl+"' width='100%' height='99%' style='overflow:hidden;padding:0px;' frameborder='0' ></iframe>",
						style:{padding:4},
						closable : true
					});
				} else {
					$('#menu_page').tabs('select',tabIndex);
				}*/
				window.open(hrefUrl,'mainAreaFrame');
			}
			function outSys(){
				$.ajax({
					type: "get",
					timeout:30000,
					url:  "${ctx}/user-login-sys-new/outSys?r="+new Date().getTime(),
					success: function(){
						parent.location = "${ctx}/user-login-sys-new/loginPwd";
					}
				});
			}
			
			function changePass(){
				$('#updatePswDialog').dialog({    
				    title:'修改密码',  
				    iconCls:'icon-view',
				    width: 300,    
				    height: 200,    
				    closed: false,    
				    inline : true,
				    cache: false,    
				    href: '${ctx}/framework/user/change-password.jsp',    
				    modal: true,
					extractor : function(data){
						if($.trim(data) == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/manage';});
								return '';
							}
						}
						return data;
					},
				    buttons : [{text:'修改',
				    		id:'updatePSWBt',
							iconCls:'icon-ok',
							handler:function(){
						    	var msn = ''||i18n[''];
						    	if($('#updatePswDataForm').form('validate')){
							    	if($('#psw').val() != $('#psw1').val()){
							    		$.messager.alert('提示',"两次输入的新密码不一致，操作失败！",'info');
							    		return;
							    	}
						    		$('#updatePSWBt').linkbutton('disable');
						    		$.ajax({
						    			type: "POST",
						    			timeout:20000,
						    			url:$('#updatePswDataForm').attr("action"),
						    			data:$("#updatePswDataForm").serialize(),
						    			success: function(data,res){
							    			var isLogin = $.trim(res.responseText);
							    			msn = msn||i18n[data];
						    				if(isLogin == "unLogin"){
						    					if(msn != undefined){
						    						$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/manage';});
						    						return ;
						    					}
						    				}
						    				if(msn == undefined){
						    					$.messager.alert('提示',i18n.serverError,'info');
						    					$('#updatePSWBt').linkbutton('enable');
						    				}else if(data == 'oldPswNoRight') {	
						    					$.messager.alert('提示','原密码输入不正确，请重新输入！','info');
						    					$('#updatePSWBt').linkbutton('enable');
						    				} else {
						    					$.messager.alert('提示',msn,'info',function(){$('#updatePswDialog').dialog('close');});
						    				}
						    			},
						    			error: function(res){
						    				$.messager.alert('提示',i18n.requestError,'error');
						    				$('#updatePSWBt').linkbutton('enable');
						    			}
						    		});
						    	}
							}
						},{
							text:'取消',
							iconCls:'icon-cancel',
							handler:function(){
								$('#updatePswDialog').dialog('close');
							}}]
				});
			}

			//通知
			$(function(){
				//初始化消息，并显示消息框
				getMessageList();
				
				//重复定时
				window.setInterval(getMessageList,1000*60*5);//1000*60*5
			});
			
			
			function initMessageList(){
				//alert($("#message").html());
				//获取通知信息
				$.ajax({
					type: "post",
					url:  "${ctx}/framework/message/messageList",
					data: {}, 
					success: function(data){ 
						var result=eval("("+data+")");
						//头
						if(result!=null&&result!=""){
							var msg="<div id='message'>"+result[0].readerName+"，您好！<br><br><div id='compettipsdiv'>";
						
							for(var i=0;i<result.length;i++){
								//if(result[i].readFlag!=1){//未读
									msg+="<div style='padding:10px 10px 10px 10px;'>"+result[i].contents
									+"<a class='readedFlag' style='float:right'  href='"+result[i].id+"'>已阅</a></div>";
								//}
							}
							msg+="</div></div>";
							
							$("#compettips").window("close");//关闭竞价公告窗口
							
							//消息框弹出
							$.messager.show({
									id:'compettips',
								    title:'消息提示',
								    msg:msg,
								    timeout:50000,
								    showType:'slide',
								 	width: 600,
					                height: 300,
								    style:{  
								        left:'',  
								        right:0,  
								        top:'',   
								        bottom:document.body.scrollTop+document.documentElement.scrollTop  
								    }  
							});
						}
						
						//已读操作
						$(".readedFlag").click(function(){
							var id=$(this);
							//id.parent().remove();
							//return false;
							//更改公告通知已读状态
							$.ajax({
								type: "post",
								url:  "${ctx}/framework/message/messageEdit",
								data: {id:id.attr("href")}, 
								success: function(data){ 
									var result=eval("("+data+")");
									if(result==true){//成功
										//移除此消息的div
										id.parent().remove();
										if($("#compettipsdiv").html()==""){
											$("#compettips").window("close");//关闭竞价公告窗口
										}
									}
								}
							});
							return false;
						});   
					}
				});
			}
			
			/**
			* 是否有新消息
			*/
			function getMessageList(){
				$.ajax({
					type: "post",
					url:  "${ctx}/framework/message/getMessageCount",
					data: {}, 
					success: function(data){ 
						if(data == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
								return ;
							}
						}
						var dataCount=parseInt(data);
						//获取消息数量
						var messageTotal=parseInt($("#messageTotal").val());
						if(messageTotal==dataCount){
							return false;
						}
						initMessageList();
						//存储消息数量
						$("#messageTotal").val(dataCount);
					}
				});
			}

            $(function(){
                //检查是否安装了flash
                var fls = flashChecker();
                if (!fls.f){
                    top.$.messager.alert('提示',"您未安装flash，请安装flash后，再进行投标!",'error',function(){
                        window.open("https://get2.adobe.com/cn/flashplayer/?no_redirect", "_blank");
                    });
                    return;
                }

            });

			function registerBank(){
			    $.ajax({
					type: "post",
					url:  "${ctx}/auction/business/registerBank",
					data: {id:"4028e44a634ded8401635da6a141000c"},
					success: function(data){
                     alert("success");
			     }

			 });
		   }



		</script>
</head>
<body>
	<div id="auctionInfoDialog"></div>
	<div id="firstLevelDialog"></div>
	<div id="secondtLevelDialog"></div>
	<div id="threeLevelDialog"></div>
	<input id="messageTotal" type="hidden" value=""/>
	<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'north',border:false" style="overflow: hidden;" >
	<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'north',border:false" style="overflow: hidden;background:url('${ctx}/commons/images/top/top_bgcolor.jpg');" >
	<center>
	<div class="topbg">
		<table style="width: 100%;">
		<!--  	<tr>
				<td style="padding-left: 20px;text-align: left;"><img src="${ctx}/commons/images/top/logo.png"></td>
				<td class="topimg" width="50%" align="right">欢迎  ${loginUser.name } 进入系统,<c:if test="${loginUser.lastLoginTime != null}" >上次登录时间：<fmt:formatDate value="${loginUser.lastLoginTime}" pattern="yyyy-MM-dd HH:mm:ss"/></c:if></td>
	           <td style="text-align: right; width:50px;padding-right: 20px;"><a href="" class="easyui-linkbutton" iconCls="icon-list">进入网站</a></td>
				<td style="width: 100px;">
				<img src="${ctx}/commons/images/top/exit.jpg" style="vertical-align: middle; "><a href="javascript:void(0);" onclick="outSys();" class="easyui-linkbutton" plain="true">安全退出</a>
				</td>
			</tr> -->
			
				<tr>
				<td style="padding-left: 20px;text-align: left;"><img src="${ctx}/commons/images/top/logo.png"></td>
				<td class="topimg" width="50%" align="right">欢迎  ${loginUser.name } 进入系统,<c:if test="${loginUser.lastLoginTime != null}" >上次登录时间：<fmt:formatDate value="${loginUser.lastLoginTime}" pattern="yyyy-MM-dd HH:mm:ss"/></c:if></td>
	           <td style="text-align: right; width: 200px;padding-right: 20px;"><a href="${ctx }/" class="easyui-linkbutton" iconCls="icon-list" plain="true">进入网站</a><br/>
				</td>
				<td style="width: 100px;">
				<img src="${ctx}/commons/images/top/exit.jpg" style="vertical-align: middle; "><a href="javascript:void(0);" onclick="outSys();" class="easyui-linkbutton" plain="true">安全退出</a>
				</td>
			</tr>
			<%--<div><button onclick="registerBank()">注册</button></div>--%>
			
		</table>
	</div>
	</center>
	</div>
	<div data-options="region:'center',border:false" style="overflow: hidden;" >
		<div id="menu" style="padding-top:2px;padding-left:50px; border:1px solid #ccc;width:100%; height: 28px;background-color: #f5f5f5;"></div>
	</div>
	</div>
	</div>
	<div data-options="region:'center',border:false" style="overflow: hidden;padding: 4px;">
	<center style="height: 100%;">
		<iframe src="${ctx}/portal/welcome.jsp" name="mainAreaFrame" id="mainAreaFrame" scrolling="auto" style="height: 100%;width: 100%;" frameborder="0" ></iframe>
	</center>
	
	</div>
	<div data-options="region:'south',border:false,href:'bottom.jsp'" style="height: 30px;"></div>
	</div>
	<div id="updatePswDialog"></div>
	<div id="showSelfDialog"></div>
</body>
</html>
